#include "stdafx.h"
#include "BluetoothTest.h"
#include "TestItemInterface.h"
#include "TestDlg.h"


CTestDlg* g_pDlg  = NULL;       

// Run test
// Return: Test result, see definition of TEST_RESULT_ENUM
TEST_RESULT_ENUM  TestItemRun()
{
	AFX_MANAGE_STATE(AfxGetStaticModuleState());

	/*CTestDlg  dlg;
	return (TEST_RESULT_ENUM)dlg.DoModal();*/
	
    RETAILMSG(TRUE, (TEXT("[MMI-BT]TestItemRun entry!\r\n")));
    if(NULL == g_pDlg)
    {        
        RETAILMSG(TRUE, (TEXT("[MMI-BT]NULL == g_pDlg continue!\r\n")));
        g_pDlg = new CTestDlg;
        g_pDlg->SearchBTDevice();
    }
    TEST_RESULT_ENUM testResult = (TEST_RESULT_ENUM)g_pDlg->DoModal();
    delete g_pDlg;
    g_pDlg = NULL;

    RETAILMSG(TRUE, (TEXT("[MMI-BT]g_pDlg = NULL!\r\n")));
    
    return testResult;
}


// Get the title of the test item
// szTitle (out) - Output the test item's title.
void TestItemGetTitle(CString& szTitle)
{
	AFX_MANAGE_STATE(AfxGetStaticModuleState());

	if (!szTitle.LoadStringW(IDS_TEST_TITLE))
	{
		szTitle = _T("Unknown");
	}
}


void TestItemDeviceSearch(void)
{
    AFX_MANAGE_STATE(AfxGetStaticModuleState());
    if(NULL == g_pDlg)
    {
        g_pDlg = new CTestDlg;
    }
    
    g_pDlg->SearchBTDevice();

    return;    
}

// Process keyboard messages
// The keyboard messages were hooked by the HiMmiTest.exe, 
// the test item's dll can implement this interface to get keyboard messages from exe,
// and if the dll don't care the keyboard message, needn't implement this function.
//
//LRESULT  TestItemProcessKbdMsg( WPARAM wParam, LPARAM lParam)
//{
//    return S_OK;
//}

